package com.tyqx.service.Impl;

import com.tyqx.bean.model.RatesInfo;
import com.tyqx.bean.model.UserHashrateInfo;
import com.tyqx.mapper.RatesInfoMapper;
import com.tyqx.mapper.UserHashrateInfoMapper;
import com.tyqx.service.RatesInfoService;
import com.tyqx.service.UserHashrateInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("ratesInfoService")
public class RatesInfoServiceImpl implements RatesInfoService {

    @Resource
    private RatesInfoMapper ratesInfoMapper;

    @Override
    public RatesInfo selectRatesInfoByDate() {
        try{
            String rateDate = ratesInfoMapper.selectRatesInfoMaxRateDate();
            return ratesInfoMapper.selectRatesInfoByDate(rateDate);
        }catch (Exception e){
            e.printStackTrace();
            RatesInfo ratesInfo = new RatesInfo();
            ratesInfo.setRates(0.0);
            return ratesInfo;
        }
    }

    @Override
    public Integer insertRatesInfo(RatesInfo ratesInfo) {
        return ratesInfoMapper.insertRatesInfo(ratesInfo);
    }

    @Override
    public Integer updateRatesInfoByDate(Double rates, String rateDate) {
        return ratesInfoMapper.updateRatesInfoByDate(rates,rateDate);
    }
}
